﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class DeThiDAL
    {
        ConnectionData conn;

        public DataTable DeThi_Load()
        {
            conn = new ConnectionData();
            return conn.GetData("DETHI_LOAD");
        }

        public int DeThi_Insert(DeThiDTO DT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "TenDeThi";
            value[0] = DT_DTO.TenDeThi;
            name[1] = "MaLoaiDe";
            value[1] = DT_DTO.MaLoaiDe;
            name[2] = "NgayLap";
            value[2] = DT_DTO.NgayLap;

            return conn.UpdateData("DETHI_INSERT", name, value, Nparameter);
        }

        public int DeThi_Update(DeThiDTO DT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaDeThi";
            value[0] = DT_DTO.MaDeThi;
            name[1] = "TenDeThi";
            value[1] = DT_DTO.TenDeThi;
            name[2] = "MaLoaiDe";
            value[2] = DT_DTO.MaLoaiDe;
            name[3] = "NgayLap";
            value[3] = DT_DTO.NgayLap;

            return conn.UpdateData("DETHI_UPDATE", name, value, Nparameter);
        }

        public int DeThi_Delete(DeThiDTO DT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaDeThi";
            value[0] = DT_DTO.MaDeThi;

            return conn.UpdateData("DETHI_DELETE", name, value, Nparameter);
        }
    }
}
